package com.pro.controller;


/*
*   赵 22/1/7
*   用户
* */
import com.pro.pojo.*;
import com.pro.service.UserService;
import javafx.scene.control.Tab;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.util.StringUtils;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;

import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.List;

@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    //赵 22/1/7 获取所有前端用户||检索||高级检索 getUsers
    @RequestMapping("/getUsers")
    public JsonData getUsers(JsBeforeUser jsBeforeUser){
        List<JsBeforeUser> users = userService.getUsers(jsBeforeUser);
        return users!=null?JsonData.buildSuccess(users):JsonData.buildError("后台数据错误");
    }

    //赵 22/1/8  普通检索用户列表 retrieval String account,String nickname,String createDate
    /*@RequestMapping("/retrieval")
    public JsonData retrieval(String account,String nickname,String createDate){
        List<JsBeforeUser> retrieval = userService.retrieval(account,nickname,createDate);
        return retrieval!=null?JsonData.buildSuccess(retrieval):JsonData.buildError("后台数据错误");
    }*/

    //赵 22/1/9 高级检索用户列表 advancedRetrieval JsBeforeUser jsBeforeUser
    /*@RequestMapping("/advancedRetrieval")
    public JsonData advancedRetrieval(JsBeforeUser jsBeforeUser){
        List<JsBeforeUser> jsBeforeUsers = userService.advancedRetrieval(jsBeforeUser);
        return jsBeforeUsers!=null?JsonData.buildSuccess(jsBeforeUsers):JsonData.buildError("后台数据错误");
    }*/

    //赵 22/1/9 修改用户信息 editUser JsBeforeUser jsBeforeUser
    @RequestMapping("/editUser")
    public JsonData editUser(JsBeforeUser jsBeforeUser){
        Boolean editUser = userService.editUser(jsBeforeUser);
        return editUser?JsonData.buildSuccess(editUser):JsonData.buildError("后台数据错误");
    }

    //赵 22/1/10 添加用户封禁信息 shutDown JsClosure jsBeforeUser
    @RequestMapping("/shutDown")
    public JsonData shutDown(JsClosure jsBeforeUser){
        Boolean shutDown = userService.shutDown(jsBeforeUser);
        return shutDown?JsonData.buildSuccess(shutDown):JsonData.buildError("后台数据错误");
    }

    //赵 22/1/10 改变用户状态 eidtStatus Integer userId
    @RequestMapping("/editStatus")
    public JsonData editStatus(Integer userId){
        Boolean editStatus = userService.editStatus(userId);
        return editStatus?JsonData.buildSuccess(editStatus):JsonData.buildError("后台数据错误");
    }


    //赵 22/1/10 获取进思用户||检索||高级检索 getJinsiUsers JsUserDevelopment jsUserDevelopment
    @RequestMapping("/getJinsiUsers")
    public JsonData getJinsiUsers(JsUserDevelopment jsUserDevelopment){
        List<JsUserDevelopment> jinsiUsers = userService.getJinsiUsers(jsUserDevelopment);
        return jinsiUsers!=null?JsonData.buildSuccess(jinsiUsers):JsonData.buildError("后台数据错误");
    }

    //赵 22/1/10 修改进思用户信息 editJinsiUser JsUserDevelopment jsUserDevelopment
    @RequestMapping("/editJinsiUser")
    public JsonData editJinsiUser(JsBeforeUser jsBeforeUser){
        Boolean editJinsiUser = userService.editJinsiUser(jsBeforeUser);
        return editJinsiUser?JsonData.buildSuccess(editJinsiUser):JsonData.buildError("后台数据错误");
    }

    //赵 22/1/11 修改进思用户，进思用户表信息  editJinsiUserJ JsUserDevelopment jsUserDevelopment
    @RequestMapping("/editJinsiUserJ")
    public JsonData editJinsiUserJ(JsUserDevelopment jsUserDevelopment){
        Boolean editJinsiUserJ = userService.editJinsiUserJ(jsUserDevelopment);
        return editJinsiUserJ?JsonData.buildSuccess(editJinsiUserJ):JsonData.buildError("后台数据错误");
    }

    /*
    *   赵 22/1/11 查询非进思用户的所有学生||检索||高级检索 getWrongJinsiUsers
    * */
    @RequestMapping("/getWrongJinsiUsers")
    public JsonData getWrongJinsiUsers(JsBeforeUser jsBeforeUser){
        List<JsBeforeUser> wrongJinsiUsers = userService.getWrongJinsiUsers(jsBeforeUser);
        return wrongJinsiUsers!=null?JsonData.buildSuccess(wrongJinsiUsers):JsonData.buildError("后台数据错误");
    }

    /*
    *   赵 22/1/11 查询零消费的所有用户||检索||高级检索 getZeroConsumptionUsers JsUserDevelopment jsUserDevelopment
    * */
    @RequestMapping("/getZeroConsumptionUsers")
    public JsonData getZeroConsumptionUsers(JsBeforeUser jsBeforeUser){
        List<JsBeforeUser> zeroConsumptionUsers = userService.getZeroConsumptionUsers(jsBeforeUser);
        return zeroConsumptionUsers!=null?JsonData.buildSuccess(zeroConsumptionUsers):JsonData.buildError("后台数据错误");
    }

    /*
     * create by: 赵自强
     * create time: 2022/1/12 11:28
     * @return com.pro.pojo.JsonData
     * 获取已封禁用户信息 getShutDownUsers JsClosure jsClosure
     */
    @RequestMapping("/getShutDownUsers")
    public JsonData getShutDownUsers(JsClosure jsClosure){
        List<JsClosure> shutDownUsers = userService.getShutDownUsers(jsClosure);
        return shutDownUsers!=null?JsonData.buildSuccess(shutDownUsers):JsonData.buildError("后台数据错误");
    }

    /*
     * create by: 赵自强
     * create time: 2022/1/12 13:46
     * @return com.pro.pojo.JsonData
     * unsealUser Integer userId,Integer status
     */
    @RequestMapping("/unsealUser")
    public JsonData unsealUser(Integer userId,Integer status){
        Boolean unsealUser = userService.unsealUser(userId, status);
        return unsealUser!=null?JsonData.buildSuccess(unsealUser):JsonData.buildError("后台数据错误");
    }

    /*
     * create by: 赵自强
     * create time: 2022/1/12 14:36
     * @return com.pro.pojo.JsonData
     * addUnsealRecord JsUnseal jsUnseal
     */
    @RequestMapping("/addUnsealRecord")
    public JsonData addUnsealRecord(JsUnseal jsUnseal){
        Boolean addjsUnseal = userService.addUnsealRecord(jsUnseal);
        return addjsUnseal!=null?JsonData.buildSuccess(addjsUnseal):JsonData.buildError("后台数据错误");
    }

    /*
     * create by: 赵自强
     * create time: 2022/1/12 15:08
     * @return com.pro.pojo.JsonData
     * 获取解封记录 getUnsealRecord JsUnseal jsUnseal
     */
    @RequestMapping("/getUnsealRecord")
    public JsonData getUnsealRecord(JsUnseal jsUnseal){
        List<JsUnseal> unsealRecord = userService.getUnsealRecord(jsUnseal);
        return unsealRecord!=null?JsonData.buildSuccess(unsealRecord):JsonData.buildError("后台数据错误");
    }

    /*
     * create by: 赵自强
     * create time: 2022/1/12 15:09
     * @return com.pro.pojo.JsonData
     * 根据id删除封禁记录 delUnsealRecord Integer id
     */
    @RequestMapping("/delUnsealRecord")
    public JsonData delUnsealRecord(Integer id){
        Boolean delUnsealRecord = userService.delUnsealRecord(id);
        return delUnsealRecord!=null?JsonData.buildSuccess(delUnsealRecord):JsonData.buildError("后台数据错误");
    }

    /*
     * create by: 赵自强
     * create time: 2022/1/13 19:05
     * @return com.pro.pojo.JsonData
     * 判断用户是否为进思用户 determineUser Integer userId
     */
    @RequestMapping("/determineUser")
    public JsonData determineUser(Integer userId){
        List<JsUserDevelopment> jsUserDevelopments = userService.determineUser(userId);
        Integer data = 0;
        if(jsUserDevelopments.size()!=0){
            data = 1;
        }else{
            data = 2;
        }
        return data!=null?JsonData.buildSuccess(data):JsonData.buildError("后台数据错误");
    }

    /*
     * create by: 赵自强
     * create time: 2022/1/13 20:22
     * @return com.pro.pojo.JsonData
     * 添加进思用户 addJinsiUsers JsUserDevelopment jsUserDevelopment
     */
    @RequestMapping("/addJinsiUsers")
    public JsonData addJinsiUsers(JsUserDevelopment jsUserDevelopment){
        Boolean addJinsiUsers = userService.addJinsiUsers(jsUserDevelopment);
        return addJinsiUsers!=null?JsonData.buildSuccess(addJinsiUsers):JsonData.buildError("后台数据错误");
    }

    /*
     * create by: 赵自强
     * create time: 2022/1/14 9:37
     * @return com.pro.pojo.JsonData
     * 获取优惠券列表 giveCoupon
     */
    @RequestMapping("/giveCoupon")
    public JsonData giveCoupon(){
        List<Coupon> coupons = userService.giveCoupon();
        return coupons!=null?JsonData.buildSuccess(coupons):JsonData.buildError("后台数据错误");
    }

    /*
     * create by: 赵自强
     * create time: 2022/1/14 10:31
     * @return com.pro.pojo.JsonData
     * 添加用户优惠券 addCcouponUsed CouponUsed couponUsed
     */
    @RequestMapping("/addCcouponUsed")
    public JsonData addCcouponUsed(CouponUsed couponUsed){
        Boolean addCcouponUsed = userService.addCcouponUsed(couponUsed);
        return addCcouponUsed!=null?JsonData.buildSuccess(addCcouponUsed):JsonData.buildError("后台数据错误");
    }

    /*
     * create by: 赵自强
     * create time: 2022/1/14 13:40
     * @return com.pro.pojo.JsonData
     * 获取创作者申请数据 getCreatorApply JsApplyRecord jsApplyRecord
     */
    @RequestMapping("/getCreatorApply")
    public JsonData getCreatorApply(JsApplyRecord jsApplyRecord){
        List<JsApplyRecord> creatorApply = userService.getCreatorApply(jsApplyRecord);
        return creatorApply!=null?JsonData.buildSuccess(creatorApply):JsonData.buildError("后台数据错误");
    }

    /*
     * create by: 赵自强
     * create time: 2022/1/14 15:23
     * @return com.pro.pojo.JsonData
     * 改变创作者申请状态&&通过申请%%驳回申请 applyAdopt JsApplyRecord jsApplyRecord
     */
    @RequestMapping("/updateApply")
    public JsonData updateApply(JsApplyRecord jsApplyRecord){
        Boolean updateApply = userService.updateApply(jsApplyRecord);
        return updateApply!=null?JsonData.buildSuccess(updateApply):JsonData.buildError("后台数据错误");
    }

    /*
     * create by: 赵自强
     * create time: 2022/1/14 15:32
     * @return com.pro.pojo.JsonData
     * 添加用户权限 addJurisdiction JsUserRole jsUserRole
     */
    @RequestMapping("/addJurisdiction")
    public JsonData addJurisdiction(JsUserRole jsUserRole){
        Boolean addJurisdiction = userService.addJurisdiction(jsUserRole);
        return addJurisdiction!=null?JsonData.buildSuccess(addJurisdiction):JsonData.buildError("后台数据错误");
    }

    /*
     * create by: 赵自强
     * create time: 2022/1/15 9:02
     * @return com.pro.pojo.JsonData
     * 获取申请通过&&驳回列表 getAdoptAndReject JsApplyRecord jsApplyRecord
     */
    @RequestMapping("/getAdoptAndReject")
    public JsonData getAdoptAndReject(JsApplyRecord jsApplyRecord){
        List<JsApplyRecord> adoptAndReject = userService.getAdoptAndReject(jsApplyRecord);
        return adoptAndReject!=null?JsonData.buildSuccess(adoptAndReject):JsonData.buildError("后台数据错误");
    }
    /*
     * create by: 赵自强
     * create time: 2022/1/15 9:54
     * @return com.pro.pojo.JsonData
     * 获取审核记录表 getAuditRecord JsAuditLog jsAuditLog
     */
    @RequestMapping("/getAuditRecord")
    public JsonData getAuditRecord(JsAuditLog jsAuditLog){
        List<JsAuditLog> auditRecord = userService.getAuditRecord(jsAuditLog);
        return auditRecord!=null?JsonData.buildSuccess(auditRecord):JsonData.buildError("后台数据错误");
    }
    /*
     * create by: 赵自强
     * create time: 2022/1/15 10:48
     * @return
     * 删除日志记录 delAuditRecord Integer auditLogId
     */
    @RequestMapping("/delAuditRecord")
    public JsonData delAuditRecord(Integer auditLogId){
        Boolean delAuditRecord = userService.delAuditRecord(auditLogId);
        return delAuditRecord!=null?JsonData.buildSuccess(delAuditRecord):JsonData.buildError("后台数据错误");
    }
}
